<!DOCTYPE html>
<html >

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        /**
      2  * [通过参数名获取url中的参数值]
      3  * 示例URL:http://htmlJsTest/getrequest.html?uid=admin&rid=1&fid=2&name=小明
      4  * @param  {[string]} queryName [参数名]
      5  * @return {[string]}           [参数值]
      6  */

        const queryName = "http://htmlJsTest/getrequest.html?uid=admin&rid=1&fid=2&name=小明";

        function GetQueryValue(str) {
            let obj = {}
            let a = str.split("?")[1].split("&")
            for(let i=0; i<a.length; i++) {
                let b = a[i].split("=")
                if(!obj.hasOwnProperty(b[0])) {
                    obj[b[0]] = b[1]
                }
            }
            return obj
        }
        const queryVal = GetQueryValue(queryName);

        console.log('参数: ', queryVal); // 小明
    </script>
</body>

</html>